package net.obxlabs.tweetpad.test;
import processing.core.*;
import twitter4j.*;
import java.util.*;

public class T2TwitterFriends extends PApplet {
    private List<T1TwitterProfile> users;
    
    public void setup() {
        size(700, 400);
        smooth();
        
        users = Collections.synchronizedList(new LinkedList<T1TwitterProfile>());

        Twitter twitter = new Twitter("prisonerjohn", "gu1tar");
        
        /*
        try {
            Status status = twitter.update("Testing the Java interface to Twitter.");
            System.out.println("Successfully updated the status to [" + status.getText() + "].");
        } catch (TwitterException te) {
            te.printStackTrace();
        }
        */
        try {
            List<User> userList = twitter.getFriends("jaspernotwell");
            UserWithStatus tempUser;
            for (ListIterator<User> i = userList.listIterator(); i.hasNext();) {
                tempUser = twitter.getUserDetail(i.next().getScreenName());
                users.add(new T1TwitterProfile(tempUser, this));
            }  
        } catch (TwitterException te) {
            te.printStackTrace();
        }
    }

    public void draw() {
        background(0);
        
        for (ListIterator<T1TwitterProfile> i = users.listIterator(); i.hasNext();) {
            i.next().draw(i.nextIndex()*70, height/3);
        }  
    }
}
